﻿#include <iostream>
#include <math.h>
#define PI 3.1415926
using namespace std;
double calculateAre(int n, double x = 1.0, double y = 1.0, double z = 1.0) {
	if (n == 1) {
		return PI * x * x;
	}
	if (n == 2) {
		return x * y;
	}
	else if (n == 3) {
		double p = (x + y + z) / 2 * 1.0;
		return sqrt(p * (p - x) * (p - y) * (p - z));
	}

}

int main() {
	cout << "请输入要计算的图形类型(1-圆形，2-矩形，3-三角形):";
	int n;
	cin >> n;
	if (n == 1) {
		cout << "请输入“圆形”的半径：";
		double r;
		cin >> r;
		cout << "该图形为圆形，其面积为：" << calculateAre(n, r);
	}
	else if (n == 2) {
		cout << "请输入“矩形”的边长：";
		double a, b;
		cin >> a >> b;
		cout << "该图形为矩形，其面积为：" << calculateAre(n, a, b);
	}
	else if (n == 3) {
		cout << "请输入“三角形”的边长：";
		double a, b, c;
		cin >> a >> b >> c;
		double res = calculateAre(n, a, b, c);
		if (res == 0) {
			cout << "输入的三遍构成不了三角形";
		}
		cout << "该图形为三角形，其面积为：" << res;
	}
	else {
		cout << "输入不合法";
		return 0;
	}
	return 0;
}
